/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.bits;

import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.component.gateway.dianlan.bits.base.BitParserBase;
import info.peigen.hotpot.component.gateway.dianlan.protocol.passive.DianlanBatteryHighTemperatureBoxDataGram;

/**
 * <b>(DianlanBatteryHighTemperatureBoxDataGramReasonBits)</b>
 * <p>
 * 电池严重高温箱体号报文-解析
 *
 * @author LiDaHai
 * @version 1.0.0
 * @since 2023/1/12
 */
public class DianlanBatteryHighTemperatureBoxDataGramReasonBits extends BitParserBase {

    public DianlanBatteryHighTemperatureBoxDataGram parseReason(String hexString) {
        String[]                                 hexStrArray = hexStrToArray(hexString);
        DianlanBatteryHighTemperatureBoxDataGram info        = DianlanBatteryHighTemperatureBoxDataGram.builder().build();
        info.setHighestTemperatureBoxNo(parseInt(hexStrArray[0]) + "");
        info.setTemperatureProbesCount(parseInt(StrUtil.sub(hexStrArray[2], 1, 2) + hexStrArray[1]));
        info.setMonomersCount(parseInt(hexStrArray[3] + StrUtil.sub(hexStrArray[2], 0, 1)));
        info.setCapacitySOH(0.4d * parseInt(hexStrArray[4]));
        info.setTotalDegrees(parseInt(hexStrArray[7] + hexStrArray[6] + hexStrArray[5]));
        return info;
    }
}